package org.company.saturn.hadoop.yarn.map;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Mapper;

/**
 * 计数器测试类，计算不合法日志的数据量
 * @author hucw
 *
 */
public class CounterMapper extends Mapper<LongWritable, Text, Text, Text> {

	private Counter ct = null;
	
	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context)
			throws IOException, InterruptedException {
		String arr_value[] = value.toString().split("/t");
		if(arr_value.length < 4) {
			ct = context.getCounter("ErrorCounter", "ERROR_LOG_TIME");
			ct.increment(1);
		}
	}
}
